
	function nbre_demiH(event){
		var heures = event.begin.split(" ")[1];
		var h_s =event.begin.split(" ")[1].split(":")[0];
		var m_s =event.begin.split(" ")[1].split(":")[1];
		var h = parseInt(h_s)
		var m = parseFloat(m_s)/30 ;
		var pixel = 21;
		return (h*2 + m)*pixel;
	}
	function duree(event){
		var duree_hh_mm = event.duree;
		
		duree_hh_mm =duree_hh_mm.split("-");
		var h_s = duree_hh_mm[0];
		var m_s = duree_hh_mm[1];
		var h = parseInt(h_s);
		var m = parseFloat(m_s)/30;
		
		var pixel = 19;
		return (h*2+m)*pixel;
	}
	function drawEvent(event) {
		console.log(event.name);
		var idDebut = event.begin.split(" ")[0];
		console.log(idDebut);
		var link = 'td.tg-col div#'+idDebut;
		var topPx = parseInt(nbre_demiH(event)); // coeficient des pixels;
		var height = duree(event);
		console.log('top ='+topPx);
		console.log('duree ='+height);
		var heureD =  event.begin.split(" ")[1].split(":")[0]+":"+event.begin.split(" ")[1].split(":")[1];
		var heureFin=  event.end.split(" ")[1].split(":")[0]+":"+event.end.split(" ")[1].split(":")[1];
		console.log(heureD);
		var div ='<div id=event'+event.id+' class="ro-chip-15 ca-evp19 chip" style="left: -1px; width: 100%;">'+'<dl id =event'+event.id+' class="cro cbrd"'+
		'style="height: 56px; border-color: #FFAD46; background-color: #FFAD46; color: #1d1d1d;">'+'<dt style="background-color:;">'+heureD+'-'+heureFin+'</dt>';
		var div1='<span class="evt-lk ca-elp19" style="cursor: pointer;">';
		var div2 ='Titre :'+event.name;
		var div3 = s3='</span></dd></dl></div>';
		$(link).append(div+div1+div2+div3);
		var balise = $('div #event'+event.id);
		console.log(balise);
		console.log(top+"px");
		balise.css("top",topPx+"px");
		balise = $('dl#event'+event.id).css("height",height+"px");
		
	}
	var listOfEvents = [#{list items:events, as:'event'}
		{name:"${event.name}", begin:"${event.begin}",end:"${event.end}",duree :"${event.getDuringClass()}",id: "${event.getId()}"},
	#{/list}];
	
	for(i=0;i<listOfEvents.length;i++) {
		drawEvent(listOfEvents[i]);
	}
	console.log(listOfEvents);